package a1_4;

import java.util.ArrayList;
import java.util.List;

/**
 * 客户类，包含个人信息及关联订单
 */
public class Customer {
    private String name;              // 姓名
    private String contact;           // 联系电话
    private String deliveryAddress;   // 邮寄地址
    private boolean active;           // 是否激活
    private List<Order> orders = new ArrayList<>(); // 关联订单（一对多）

    public Customer() {}

    public Customer(String name, String contact, String deliveryAddress, boolean active) {
        this.name = name;
        this.contact = contact;
        this.deliveryAddress = deliveryAddress;
        this.active = active;
    }

    // 添加订单（一对多关联）
    public void addOrder(Order order) {
        orders.add(order);
        order.setCustomer(this); // 双向关联，同步订单的客户
    }

    // Getter/Setter
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContact() {
        return contact;
    }

    public void setContact(String contact) {
        this.contact = contact;
    }

    public String getDeliveryAddress() {
        return deliveryAddress;
    }

    public void setDeliveryAddress(String deliveryAddress) {
        this.deliveryAddress = deliveryAddress;
    }

    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }

    public List<Order> getOrders() {
        return new ArrayList<>(orders);
    }
}
